<template>
	<view class="repair-wrap">
		<view class="u-m-t-20 repair-box u-p-40 u-p-l-30 u-p-r-30" v-for="(item,index) in tabeData"
			@click="detail(item.id)">
			<view class="nav_item">
				<view style="display: flex;">
					<!-- 红点提醒-->
					<view v-show="item.dot == true"
						style="width: 7px;height: 7px;border-radius: 7px;background-color: #FF3B30;position: relative;top: 9px;right: 10px;">
					</view>
					<image style="width: 17px;height: 16px;padding-right: 7px;" src="https://clhy-img.oss-cn-beijing.aliyuncs.com/ownerImage/rentsale.png" alt=""></image>
					
					<h3>{{item.project_name}}</h3>
				</view>
				<view style="float: right;margin-top: -24px;"  v-if="item.release_type == 1">
					<view class="notice-typePuTong" v-if="item.rent_state == 1">已发布</view>
					<view class="notice-type" v-if="item.rent_state == 3">已下线</view>
					<view class="notice-typeBlue" v-if="item.rent_state == 2">已租</view>
				</view>
				<view style="float: right;margin-top: -24px;" v-if="item.release_type == 2">
					
					<view class="notice-typePuTong" v-if="item.sell_state == 1">已发布</view>
					<view class="notice-type" v-if="item.sell_state == 2">已下线</view>
				</view>
				
				<view style="display: flex;justify-content: space-between;margin-top: 10px;">
					<view style="display: flex;color: #000000;">
						<view style="color: #999">楼宇：</view>
						<view>{{item.area_number}}-{{item.floor_number}}-{{item.unit_number}}-{{item.house_number}}</view>
					</view>
					<view style="display: flex;color: #666;">
						<view style="color: #999">房屋类型：</view>
						<view>{{item.house_type}}</view>
					</view>
				</view>
				<view style="display: flex;margin-top: 7px;color: #666;">
					<view style="color: #999">房屋户型：</view>
					<view>{{item.house_types}}</view>
				</view>
				<view style="display: flex;margin-top: 7px;color: #666;" v-if="item.payment_method!= null">
					<view style="color: #999">支付方式：</view>
					<view>{{item.payment_method}}</view>
				</view>
				<view style="display: flex;margin-top: 7px;color: #666;">
					<view style="color: #999">面积：</view>
					<view>{{item.built_area}}平方米</view>
				</view>
				<view style="display: flex;margin-top: 7px;color: #666;" v-if="item.total_money != null">
					<view style="color: #999">总金额：</view>
					<view>{{item.total_money | moneyFormat}}元</view>
				</view>
				<view style="margin-top: -19px;text-align: right;">
					<view style="color: #999;">{{item.begin_time.substr(0,10)}}</view>
				</view>
			</view>
		</view>
		<!-- <view style="margin-top: 50px;">
			<button class="yilingqu" @click="release">发布租售信息</button>
		</view> -->
		<view class="add-process"  @click="release">
			<image style="width: 40px;height: 40px;" src="https://clhy-img.oss-cn-beijing.aliyuncs.com/ownerImage/tenAddDatas.png" mode=""></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tabeData: [],
				ruleFrom: {
					pageIndex: 1,
					release_type: null, //发布类型1.租2.售
					above: null, //价位开始
					follow: null, //价位结束
				}
			}
		},
		onShow() {
			let _this = this
			if (uni.getStorageSync('phone')) {
				if (uni.getStorageSync('loginFlag')) {
					if (!uni.getStorageSync('hourseList')) {
						this.$openInvite()
					} else {
						_this.showFlag = true
						_this.homelist = uni.getStorageSync('hourseList')[uni.getStorageSync('hourseNum') || 0]
						_this.name = _this.homelist.proName;
						_this.address = _this.homelist.buildDistrictCode + '-' + _this.homelist.buildTowerCode + '-' +
							_this.homelist.roomUnitNumber + '-' + _this.homelist.roomCode
						// _this.getRepaireClass()
					}
				} else {
					uni.showModal({
						title: '请先实名认证',
						showCancel: false,
						confirmText: '确认',
						confirmColor: '#F9A832',
						success: function(res) {
							if (res.confirm) {
								_this.$Router.push({
									path: '/homePage1/realName/realName'
								})
							}
						}
					});
				}
			} else {
				uni.showModal({
					title: '请先登录',
					showCancel: false,
					confirmText: '确认',
					confirmColor: '#F9A832',
					success: function(res) {
						if (res.confirm) {
							console.log('a')
							_this.$Router.pushTab({
								path: '/pages/user/user'
							})
						}
					}
				});
			}
			this.getrelesaList()
		},
		onPullDownRefresh() {
			this.getrelesaList()
		},
		filters: {
			//取截单元,单位  zwl 2022-11-1
			moneyFormat: function(arg) {
				if (arg == null || arg == '') {
					return 0
				}
				if (arg.toString().length >= 13) {
					// return arg/1000000000000+"万亿"
					const moneys = arg / 1000000000000
					const realVal = parseFloat(moneys).toFixed(2);
					return realVal + "万亿"
		
				} else if (arg.toString().length >= 9) {
					const moneys = arg / 100000000
					const realVal = parseFloat(moneys).toFixed(2);
					return realVal + "亿"
				} else if (arg.toString().length >= 5) {
					const moneys = arg / 10000
					const realVal = parseFloat(moneys).toFixed(2);
					return realVal + "万"
				} else {
					return arg
				}
			}
		},
		methods: {
			getrelesaList() {
				uni.showLoading({
					title: "加载中"
				})
				this.$request.api.listRelese({
					pageIndex: this.ruleFrom.pageIndex,
					release_type: this.ruleFrom.release_type,
					above: this.ruleFrom.above,
					follow: this.ruleFrom.follow,
				}).then(res => {

					console.log(res)
					this.tabeData = res.data.data.datalist
					console.log(this.tabeData)
					uni.hideLoading()
				})
				uni.stopPullDownRefresh()
			},
			release() {
				uni.navigateTo({
					url: '/my/pages/rentsale/release'
				})
			},
			detail(id) {
				uni.navigateTo({
					url: '/my/rentsale/detailrentsale?id=' + id
				})
			},
			natov(url) {
				uni.navigateTo({
					url: url
				})
			},
		}
	}
</script>


<style lang="scss">
	.repair-wrap {
		width: 100%;
		min-height: 100vh;
		height: auto;
		background: #f4f4f4;
		overflow: hidden;

		.repair-box {
			background: #fff;

			.repair-titel {
				height: 44rpx;
				line-height: 44rpx;

				.repair-titel-l {
					float: left;
				}

				.repair-titel-r {
					float: right;
					color: #999;
				}
			}

			.repair-6 {
				color: #666;
			}
		}
	}

	.yilingqu {
		width: 80%;
		height: 84rpx;
		// background:#F9A832;
		// background-color: #F9A832;
		background: linear-gradient(180deg, #76D904 0%, #417505 100%);
		border-radius: 44rpx;
		line-height: 84rpx;
		color: #FFFFFF;
		text-align: center;
		font-size: 32rpx;
	}
	.notice-type{
		width: 64px;
		padding: 10rpx 20rpx;
		background: linear-gradient(90deg, #b2abab 0%, #b2abab 100%);
		border-radius: 20rpx 0;
		text-align: center;
		color: #fff;
	}
	.notice-typePuTong{
		width: 64px;
		background: linear-gradient(90deg, #00aa00 0%, #55aa00 100%);
		border-radius: 20rpx 0;
		text-align: center;
		color: #fff;
		padding: 10rpx 20rpx;
	}
	.notice-typeBlue{
		width: 64px;
		padding: 10rpx 20rpx;
		background: linear-gradient(90deg, #578ae7   0%, #3d7fff 100%);
		border-radius: 20rpx 0;
		text-align: center;
		color: #fff;
	}
	.add-process {
		position: fixed;
		right: 36rpx;
		bottom: 230rpx;
	
	}
</style>
